/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.buss.core.validator;

/**
 *
 * @author gykl
 */
public class RegularValidator {

    //验证是否为EMAIL格式
    public final static String EMAIL = "('')|(\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*)";

    //验证电话号码
    public final static String TELEPHONE = "('')|(\\d{4}(-*)\\d{8}|\\d{4}(-*)\\d{7}|\\d{3}(-*)\\d{8}|\\d{3}(-*)\\d{7})";

    //验证手机号码
    public final static String MOBILEPHONE = "1(3|5|8)\\d{9}";//"[1][3|5|8]+\\d{9}";

    //是否全部为中文
    public final static String CHINESECHAR = "^[\u4e00-\u9fa5]+$";

    //检查字符串中是否还有HTML标签
    public final static String HTMLTAGHAS = "<(\\S*?)[^>]*>.*?</\\1>|<.*? />";

    //检查URL是否合法
    public final static String URL = "[a-zA-z]+://[^\\s]*";

    //检查IP是否合法
    public final static String IP = "\\d{1,3}+\\.\\d{1,3}+\\.\\d{1,3}+\\.\\d{1,3}";

    //检查QQ号是否合法
    public final static String QQ = "[1-9][0-9]{4,13}";

    //检查邮编是否合法
    public final static String POSTCODE = "[1-9]\\d{5}(?!\\d)";

    /**
     * 检查身份证是否合法
     * 验证时请先验证长度是否为15为或者18位
     */
    public final static String IDCARD = "\\d{6}(19|20)*[0-99]{2}(0[1-9]{1}|10|11|12)(0[1-9]{1}|1[0-9]|2[0-9]|30|31)(\\w*)";

    public static void main(String[] args){
        String val = "5113211982081010000";
        System.out.println(val.matches(IDCARD));
    }

}
